<template>
    <div class="m-window"> 
         <el-row :gutter="10" style="margin:8px auto;">
             <el-col :span="2">
                <el-button type="primary" @click="backToMyList">返回</el-button>
            </el-col>
            
        </el-row>
        <el-row :gutter="10" class="footer-btns-col">
            <el-col :span="2" v-show="pageSourceCode != 'myProcessed'">
                <el-button type="primary" @click="sendBack">退回</el-button>
            </el-col>
            <el-col :span="2" v-show="pageSourceCode != 'myProcessed'">
                <el-button type="primary" @click="pass">通过</el-button>
            </el-col>
            
        </el-row>
        <!-- <div class="package-col">
             <browse-contract
                :account="account"
                :applyId="applyId"
                :contentColHeight="contentColHeight"/>
        </div> -->
        <el-row>
            <el-col :span="12">
                <el-form :v-model="lawApprovalTableForm" ref="lawApprovalTableForm">
                    <el-form-item>
                        <table class="emphasis-table">
                        <tr>
                            <th>流程编号：</th>
                            <td class="hit font-underline">{{lawApprovalTableForm.item_no}}</td>
                        </tr>
                        <tr>
                            <th>供应商名称：</th>
                            <td>{{lawApprovalTableForm.cust_name}}</td>
                        </tr>             
                        <tr>
                            <th>融资金额：</th>
                            <td>{{getFormatApplyAmt}} 元</td>
                        </tr>
                        <tr>
                            <th>融资产品：</th>
                            <td>{{lawApprovalTableForm.fin_type}}</td>
                        </tr>
                        <tr>
                            <th>融资开始日期：</th>
                            <td>{{lawApprovalTableForm.apply_date}}</td>
                        </tr>
                        <tr>
                            <th>融资到期日期：</th>
                            <td>{{lawApprovalTableForm.prepayback_date}}</td>
                        </tr>
                        <tr>
                            <th>融资天数：</th>
                            <td>{{getDayAmount}}</td>
                        </tr>
                        <!-- <tr>
                            <th>利率：</th>
                            <td>{{showRate}}</td>
                        </tr>
                        <tr>
                            <th>预扣：</th>
                            <td>{{getPreDeductAmount}} 元</td>
                        </tr>
                        <tr>
                            <th>到账金额：</th>
                            <td>{{getArrivalAmount}} 元</td>
                        </tr>
                        <tr>
                            <th>还款金额：</th>
                            <td>{{getFormatApplyAmt}} 元</td>
                        </tr> -->
                        <tr>
                            <th>金融客服：</th>
                            <td>{{lawApprovalTableForm.apply_user}}</td>
                        </tr>
                        <tr>
                            <th>客服电话：</th>
                            <td>{{lawApprovalTableForm.apply_phone}}</td>
                        </tr>
                        
                        </table>
                    </el-form-item>
                </el-form>
            </el-col>
        </el-row>
        <el-row>
            <el-col>
                <ul class="file-col">
                    <li v-for="(v,i) in contractList" :key="i">
                        <a href="javascript:;" v-text="`${i+1}. ${v.name}`"></a>
                        <el-button class="mini" @click="previewContract(v)">预览</el-button>
                        <el-button class="mini" @click="downloadFile(v)">下载</el-button>
                    </li>
                </ul>
            </el-col>
        </el-row>
        <el-row style="margin-top:20px;">
            <el-col>
                 <el-form :model="lawApprovalForm" ref="lawApprovalForm">
                     <el-form-item prop="isNakedin">
                        <el-checkbox label="已中登" v-model="lawApprovalForm.isNakedin" :disabled="pageSourceCode == 'myProcessed'"/> 
                        <div class="files-col">
                            <a href="javascript:;" v-for="(v,i) in zdExcels" :key="i" :title="v.orgName" @click="fileDownload(v.orgName,v.fileName,'excel')">
                                <i class="icon el-icon-download"></i>
                                <span>{{v.orgName}}</span></a>
                        </div>
                    </el-form-item>
                    <el-form-item prop="note" style="margin-top:-8px;">
                        <label>退回原因 &nbsp;<i class="el-icon-warning"></i></label>
                        <el-input type="textarea" v-model.trim="lawApprovalForm.note" placeholder="退回原因" :disabled="pageSourceCode == 'myProcessed'" />
                    </el-form-item>
                </el-form>
            </el-col>
        </el-row>
        <!-- 弹窗 -->
        <el-dialog title="合同校验" :visible.sync="multiModel" width="100%"    :close-on-click-modal="false">
            <div class="dialogMain">
                <div class="dialogLeft" >
                    <div class="sureIcon">
                            <el-button type="primary" @click="sureSave()">确认核对无误</el-button>
                    </div>
                    <div class="saveleft" @click="tapSave" :class="!isSave ? 'saveleftposition' : '' ">{{isSave?"《":"》"}}</div>
                    <el-row v-if="isSave" >
                        <el-col :span="10">
                            <el-form :v-model="lawApprovalTableForm" ref="lawApprovalTableForm">
                                <el-form-item>
                                    <table class="emphasis-table">
                                    <tr>
                                        <th>流程编号：</th>
                                        <td class="hit font-underline">{{lawApprovalTableForm.item_no}}</td>
                                    </tr>
                                    <tr>
                                        <th>供应商名称：</th>
                                        <td>{{lawApprovalTableForm.cust_name}}</td>
                                    </tr>
                                    <tr>
                                        <th>供应商收款银行：</th>
                                        <td>{{lawApprovalTableForm.bank}}</td>
                                    </tr>
                                    <tr>
                                        <th>供应商收款账号：</th>
                                        <td>{{lawApprovalTableForm.bankNo}}</td>
                                    </tr>
                                    <tr>
                                        <th>供应商收款账户：</th>
                                        <td>{{lawApprovalTableForm.name}}</td>
                                    </tr>              
                                    <tr>
                                        <th>融资金额：</th>
                                        <td>{{getFormatApplyAmt}} 元</td>
                                    </tr>
                                    <tr>
                                        <th>融资产品：</th>
                                        <td>{{lawApprovalTableForm.fin_type}}</td>
                                    </tr>
                                    <tr>
                                        <th>融资开始日期：</th>
                                        <td>{{lawApprovalTableForm.apply_date}}</td>
                                    </tr>
                                    <tr>
                                        <th>融资到期日期：</th>
                                        <td>{{lawApprovalTableForm.prepayback_date}}</td>
                                    </tr>
                                    <tr>
                                        <th>融资天数：</th>
                                        <td>{{getDayAmount}}</td>
                                    </tr>
                                    <tr>
                                        <th>利率：</th>
                                        <td>{{showRate}}</td>
                                    </tr>
                                    <tr>
                                        <th>预扣：</th>
                                        <td>{{getPreDeductAmount}} 元</td>
                                    </tr>
                                    <tr>
                                        <th>到账金额：</th>
                                        <td>{{getArrivalAmount}} 元</td>
                                    </tr>
                                    <tr>
                                        <th>还款金额：</th>
                                        <td>{{getFormatApplyAmt}} 元</td>
                                    </tr>
                                    <tr>
                                        <th>金融客服：</th>
                                        <td>{{lawApprovalTableForm.apply_user}}</td>
                                    </tr>
                                    <tr>
                                        <th>客服电话：</th>
                                        <td>{{lawApprovalTableForm.apply_phone}}</td>
                                    </tr>
                                    
                                    </table>
                                </el-form-item>
                            </el-form>
                        </el-col>
                    </el-row>
                </div>
                
                <div class="dialogRight" :class="isSave? 'dialogRightpadleft' : '' ">
                    <div class="dialogRightmain">
                        <div class="dialogRighttop" v-show="isTible">
                            <ag-grid-vue
                                class="ag-theme-balham ag-table"
                                :gridOptions="applyGridOptions"
                                :columnDefs="applyColumnDefs"
                                :rowData="applyRowData"
                                v-loading="applyLoading"
                                ></ag-grid-vue>
                                <pagination
                                    :config="{pageNumberChanged, pageSizeChanged, pageNumber: 1,justifyContent:'flex-end'}"
                                    :total="letterListTotal"
                                ></pagination>
                        </div>
                        <div class="dialogRighttitle">
                            <H3>合同预览</H3>
                            <el-button @click="lookTible" >查看对账函列表</el-button>
                        </div>
                        <div class="dialogRightbody">
                            <iframe 
                                :src="contractSrc" 
                                height="100%" 
                                width="100%" 
                                frameborder="0"></iframe>  
                        </div>
                    </div>
                </div>

            </div>
        </el-dialog>
   </div>
</template>
<style lang="less" scoped>
    .m-window{
        overflow: auto;
        overflow-x: hidden;
        padding-bottom: 40px;
        .package-col{
            position:relative;
            width: 100%;
            height: auto;
        }
        /deep/ .el-dialog{
            margin-top: 0 !important; 
            height: 100%;
                /deep/ .el-dialog__body{
                position: absolute;
                top: 50px;
                right: 0;
                left: 0;
                bottom: 0;
            }
        }
        .file-col {
            padding-left: 20px;
            li{
                margin: 10px 0;
            }
        }
    }
    .line-mar-t{
        margin-top:20px;
    }
    .emphasis-table {
        width: 100%;
        margin-top: 10px;
        td,
        th {
            border: 1px solid #eee;
            padding: 0 10px;
            height: 38px;
            width: 50%;
            text-align: right;
        }
        & tr:nth-child(even) th,
        & tr:nth-child(even) td {
            background: #f9fafa;
        }
        .font-underline {
            text-decoration: underline;
        }
        .hit {
            color: #409eff !important;
        }
        td {
            text-align: left;
            & /deep/.el-input {
            .el-input__inner {
                border: none !important;
                outline-style: none !important;
                height: 35px;
                line-height: 35px;
                margin-left: -10px;
            }
            .el-input__icon {
                margin-left: -10px;
                margin-top: -2px;
            }
            }
        }
         
    }
    
    .underline{
        text-decoration: underline;
        color: #409EFF !important;
        display: inline-block;
        margin:0 10px;
    }
    .el-col-10{
        width: 100% !important;
    }
    .el-button.mini{
            height:20px !important;
            width:50px !important;
            line-height:20px !important;
            padding: 0 !important;
    }
    .dialogMain{
        position: relative;
        width:100%;
        height: 96%;
        // overflow: auto;
    }
    .dialogLeft,.dialogRight{
        position: absolute;
        left: 0;
        top: 0;
        bottom: 0;
        right: 0;
    }
    .dialogLeft{
        width: 30%;
        padding-top: 40px;
       
    }
   
    .dialogRight.dialogRightpadleft{
        padding-left:31%;
    }
    .dialogRightmain{
        width: 100%;
        height: 100%;
        position: relative;
    }
    .dialogRighttop{
        position: absolute;
        top: 50px;
        background: #ffffff;
        border: 1px solid #959697;
        width: 100%;
        height: 200px;
        overflow: auto;
    }
    .dialogRighttitle{
        line-height: 50px;
        font-size: 16px;
        text-align: center;
        font-weight: bold ;
        overflow: hidden ;
        position: relative;
    }
    .dialogRighttitle>button{
        position: absolute;
        right:20px;
        top:0px;
    }
    .dialogRightbody{
        height:95%;
        // overflow-x: auto;
    }
    .ag-table {
      height: 150px;
      width: 100%;
      margin-top: 8px;
    }
    .saveleft{
        position: absolute;
        right: 0;
        top:35%;
        width: 20px;
        height: 58px;
        background: #409EFF;
        font-size: 16px;
         z-index: 111;
         line-height: 58px;
    }
    .saveleftposition{
        left:0
    }
    .footer-btns-col,.header-btns-col{
        position:fixed;
        height: 60px;
        width: 100%;
        bottom: 0;
        z-index: 10;
        margin-left: -11px !important;
        box-sizing:border-box;
        display: flex;
        justify-content: center;
        align-items:center;
        background: #fff;
        padding: 10px 0;
        border-top: 1px solid #eee;
        /deep/ .el-button{
        margin-left: -84px;
        }
    }
    .header-btns-col{
        top: 0;
        justify-content: flex-start;
        border-top: none;
        border-bottom: 1px solid #eee;
        margin-top: 100px;
        /deep/ .el-button{
        margin-left: 8px;
        }
    }
   

</style>
<script>
import gridOptions from "lesso-common/public/gridOptions";
import pagination from '@/components/pagination.vue';
import { showAlert } from "lesso-common/public/utils";
import { formatRate,formatPrice, dateDiff, getSpecifyDate,numberMul,numberSub } from "@/util/format.js";
import { mapState,mapActions } from 'vuex'
import { download } from '@/util/fileDownload.js'

export default {
    props:['pageSourceCode'],
    data(){
        return {
            checkTab:'',
            contentColHeight:680,
            lawApprovalForm:{
                isNakedin:false,//是否中登
                result:1, //0 未到达、1 待审批、2 通过 、3 退回
                note:'' //退回原因
            },
            examinePass:2, //2 通过
            examineNotgo:3, //3 退回
            linkName:'act_fin_review_reg', //流程环节名称
            account:'', //电子签账号
            applyId:'', //申请ID
            flowStepCode:0, //步骤码
            multiModel:false,  //是否显示弹窗
            isTible:false,  //是否显示对账函
            contractSrc:"",  //网页地址
            applyGridOptions: {},
            applyColumnDefs: [],
            applyRowData: [],
            applyLoading: false,
            previewDialogVisible:false,
            contractList:[],
            pageListParams:{
                entity: {"applyId":''},
                current: 1,
                size: 10
            },
            letterListTotal: 0,
            lawApprovalTableForm: {
                id: "",
                item_no: "",
                cust_name: "",
                apply_amt: 0,
                fin_type: 0,
                apply_date: "",
                dayAmount: 0,
                service_rate: 0,
                preDeductAmount: 0,
                arrivalAmount: 0,
                apply_user: "",
                apply_phone: "",
                prepayback_date: "",
                bank:"",
                bankNo:"",
                name:""
            },
            isSave:true,
            zdExcels:[],
            pactNo:false,
            messageNo:false,
            pactValue:0,
            messageValue:0
        }
    },
    created(){
        this.account = this.supplyChainFinance.role.eSignAccount 
        this.applyId = this.supplyChainFinance.role.ID
        this.pageListParams.entity.applyId = this.applyId
        // this.account = "SRMG100046" 
        // this.applyId = "55a5e86b-4556-44a1-a9c6-2411d7f567b7"
        this.applyGridOptions = gridOptions();
        this.applyColumnDefs = [
            {
                checkboxSelection: false, //是否显示复选框
                headerCheckboxSelection: false, //是否显示全选框
                headerName: "买方公司",
                field: "companyName",
                width: 180
            },
            {
                checkboxSelection: false, //是否显示复选框
                headerCheckboxSelection: false, //是否显示全选框
                headerName: "商务合同编号",
                field: "letterNo"
            },
            {
                headerName: "对账函编号",
                field: "accountCode",
                width: 150
            },
            {
                headerName: "对账函月份",
                field: "letterMonth",
                width: 100
            },
            {
                headerName: "应收",
                field: "payBalance",
                width:130,
                valueFormatter:params=>{
                    return formatPrice(params.value)
                }
            },
            {
                headerName: "本次使用金额",
                field: "actBalance",
                width:130,
                valueFormatter:params=>{
                    return formatPrice(params.value)
                }
            },
            // {
            //     headerName: "可融金额",
            //     field: "borrowBalance"
            // },
            {
                headerName: "融资状态",
                field: "finStatus",
                cellRenderer: function(params) {
                if (params.value != undefined && params.value == 1) {
                    return "部分融资";
                } else if (params.value == 2) {
                    return "已融资";
                } else {
                    return "未融资";
                }
                },
                width:100
            }
        ];   
        if(this.applyId) {
            let params={
                id:this.applyId
            }
            this.getTablelist(params)
            
        }
        this.loadContract()
        this.getZDExcel()
    },
    computed: {
        ...mapState(['supplyChainFinance']),
         //显示利率
        showRate() {
            return formatRate(this.lawApprovalTableForm.service_rate) + "/天";
        },
        //获取预扣金额
        getPreDeductAmount() {
            this.lawApprovalTableForm.preDeductAmount = numberMul(numberMul(this.lawApprovalTableForm.apply_amt,this.lawApprovalTableForm.service_rate),this.lawApprovalTableForm.dayAmount).toFixed(2)
            return formatPrice(this.lawApprovalTableForm.preDeductAmount);
        },
        getArrivalAmount() {
            this.lawApprovalTableForm.arrivalAmount = numberSub(this.lawApprovalTableForm.apply_amt,this.lawApprovalTableForm.preDeductAmount).toFixed(2)
            return formatPrice(this.lawApprovalTableForm.arrivalAmount);
        },
        getDayAmount() {
            this.lawApprovalTableForm.dayAmount = dateDiff(
                this.lawApprovalTableForm.apply_date,
                this.lawApprovalTableForm.prepayback_date
            );
            return this.lawApprovalTableForm.dayAmount + "天";
        },
        //获取融资到期日
        getPaybackDate() {
            return getSpecifyDate(25);
        },
        getFormatApplyAmt(){
            return formatPrice(this.lawApprovalTableForm.apply_amt)
        }
    },
    methods:{
         ...mapActions([
            'changeTOdo',
            'changeMyProcessedCTCode'
        ]),
        async commonUpdate(){
            let that = this
            let parameter = Object.assign({},{
                name:that.linkName,
                applyId:that.applyId
            },that.lawApprovalForm)
            await that.$http.commonUpdate(parameter).then(({data})=>{
                
                if(data.code == 200){
                    showAlert({
                        msg: `操作成功！`,
                        type: 1
                    })
                   that.changeTOdo({isMyToDoList:that.flowStepCode})
                }else{
                    this.$alert(`操作失败：${data.info}`, {
                        confirmButtonText: "确定",
                        customClass: "alertFailure",
                        callback:()=>{
                            if(that.lawApprovalForm.isNakedin){
                                that.lawApprovalForm.isNakedin = false
                                that.signature()
                            }
                        }
                    })
                }
            })
            .catch((error)=>{
                this.$alert("查询失败，请检查网络！", {
                    confirmButtonText: "确定",
                    customClass: "alertFailure"
                })
            })
        },
        async signature(){
            let that = this
            await that.$http.tblFinSrmApplyInfo({
                'id':that.applyId,
                'isNakedin':that.lawApprovalForm.isNakedin? 1:0
            }).then(({data})=>{
                if(data.code == 200){
                    that.commonUpdate()          
                }else{
                    showAlert({
                        msg: `操作失败：${data.info}`,
                        type: 0
                    })
                }
            }).catch((error)=>{
                this.$alert("查询失败，请检查网络！", {
                    confirmButtonText: "确定",
                    customClass: "alertFailure"
                })
            })
        },
        //获取中登文件
        async getZDExcel(){
            let that = this
            await that.$http.createZDExcel({
                'applyId':that.applyId
            }).then(({data})=>{
                if(data.code == 200){
                    that.zdExcels = data.rows || []
                }else{
                    showAlert({
                        msg: `操作失败：${data.info}`,
                        type: 0
                    })
                }
            }).catch((error)=>{
                this.$alert("查询失败，请检查网络！", {
                    confirmButtonText: "确定",
                    customClass: "alertFailure"
                })
            })
        },
        pass(){     
            if(!this.lawApprovalForm.isNakedin){
                showAlert({
                    msg: "请勾选“已中登”选项",
                    type: 2
                })
                return
            }   
            if(this.pactValue<1||this.messageValue<1){
                if(this.pactValue<1){
                    this.$alert("请预览保理服务合同之后确定核对无误", {
                        confirmButtonText: "确定",
                        customClass: "alertFailure"
                        });
                        return
                }
                if(this.messageValue<1){
                    this.$alert("请预览应收账款转让通知函之后确定核对无误", {
                        confirmButtonText: "确定",
                        customClass: "alertFailure"
                        });
                        return
                }
                
            }else{
                this.$confirm('是否确认通过？').then(_ => {
                    this.lawApprovalForm.result = this.examinePass
                    this.lawApprovalForm.note = ''
                    this.flowStepCode = 0
                    this.signature()
                })
                .catch(_ => {})
            }  
            
        },
        sendBack(){
            if(this.lawApprovalForm.isNakedin){
                showAlert({
                    msg: "当前申请已中登不允许退回",
                    type: 2
                })
                return
            }
            if(!this.lawApprovalForm.note){
                 showAlert({
                    msg: "请填写退回原因",
                    type: 2
                })
                return
            }    
            this.$confirm('是否确认退回？').then(_ => {
                this.lawApprovalForm.result = this.examineNotgo
                this.lawApprovalForm.isNakedin = false
                this.flowStepCode = 0
                this.commonUpdate()
            })
        },
        backToMyList(){
            if(this.pageSourceCode == 'myProcessed'){
                this.changeMyProcessedCTCode('')
            }else{
                this.changeTOdo({isMyToDoList:0})
            }             
        },
        //预览合同
        previewContract(v){
            if(v.name=="《保理服务合同》"){
                this.pactNo=true
            }
            if(v.name=="《应收账款转让通知函》"){
                this.messageNo=true
            }
            this.multiModel = true;
            this.contractSrc = 'about:blank'
            this.loadContract(v.docId)
            this.previewDialogVisible = true
        },
        //下载合同文件
        downloadFile(v){
            this.fileDownload(v.name,v.path,'pdf')
        },
        lookTible(){
            this.isTible=!this.isTible
            this.getPageLetterlist(this.pageListParams)
        },
        //获取主表信息
        getTablelist(params){
            var that=this
            this.$http.getApplyInfo(params).then(response => {
                    if (response.data.code == 200) {
                        console.log(response.data)
                        let data = response.data.rows;
                        if(data.processStatus == 0){
                        this.wfType = 1//天进宝300万以下
                        }else{
                        this.wfType = 2//天进宝300万以上
                        }
                        that.lawApprovalTableForm.id = data.id
                        that.lawApprovalTableForm.item_no = data.itemNo
                        that.lawApprovalTableForm.cust_name = data.custName
                        that.lawApprovalTableForm.apply_amt = data.applyAmt? data.applyAmt : 0
                        that.lawApprovalTableForm.fin_type = data.finType == 0 ? "天进宝" : "月有钱"
                        that.lawApprovalTableForm.service_rate = data.serviceRate ? data.serviceRate : 0
                        that.lawApprovalTableForm.apply_user = data.applyUser
                        that.lawApprovalTableForm.apply_phone = data.applyPhone
                        that.lawApprovalTableForm.prepayback_date = data.prepaybackDate? data.prepaybackDate.substring(0,10) : ''
                        that.lawApprovalTableForm.apply_date = data.applyDate? data.applyDate.substring(0,10) : ''
                        that.lawApprovalTableForm.bank=data.custEsignBank?data.custEsignBank:""
                        that.lawApprovalTableForm.bankNo=data.custEsignBankno?data.custEsignBankno:""
                        that.lawApprovalTableForm.name=data.custEsignName?data.custEsignName:""
                    } else {
                        that.$alert("获取申请表信息失败", {
                        confirmButtonText: "确定",
                        customClass: "alertFailure"
                        });
                    }
                })
                .catch(errror => {
                    this.$alert("查询主表信息失败，请检查网络！", {
                        confirmButtonText: "确定",
                        customClass: "alertFailure"
                    });
                });
        },
        //查询申请关联对账函
        getPageLetterlist(params){
            this.$http.getApplyLetter(params).then(response => {
                if (response.data.code == 200 && response.data.rows.length > 0) {
                this.applyRowData = response.data.rows;
                this.letterListTotal = response.data.total
                } else {
                this.applyRowData = []
                this.letterListTotal = 0
                this.$alert(response.data.info, {
                    confirmButtonText: "确定",
                    customClass: "alertFailure"
                });
                }
            })
            .catch(errror => {
                this.$alert("获取对账函信息失败，请检查网络！", {
                confirmButtonText: "确定",
                customClass: "alertFailure"
                });
                this.applyRowData = []
                this.letterListTotal = 0
            });
        },
        pageNumberChanged(pageNumber) {
            this.pageListParams.current = pageNumber
            this.getPageLetterlist(this.pageListParams)
        },
        pageSizeChanged(pageSize) {
            this.pageListParams.current = 1
            this.pageListParams.size = pageSize
            this.getPageLetterlist(this.pageListParams)
        },
        //请求合同的src
        async loadContract(docId){
            this.loading = true
            let that = this
            let param = {
                account:this.account,
                applyId:this.applyId
            }
            await this.$http.createToken(param).then(({data})=>{
                if(data.code == 200 && data.rows.contractList){
                    let token = data.rows.token
                    if(docId){
                         data.rows.contractList.forEach(function(value, index, array) {
                            if(value.docId == docId){
                                that.contractSrc = `https://esign.lesso.com/testesign/SSOSign/SignLogin?param=${token}&url=https://esign.lesso.com/TestEsign/Sign/indexView?doc_id=${value.docId}`
                            }
                        })
                    }else{
                        that.processNumber = data.rows.contractList.length>0? data.rows.contractList[0]['itemNo'] : ''
                        that.contractList = data.rows.contractList
                    }
                }
                setTimeout(function(){
                    that.loading = false
                },600)
            })
            .catch((error)=>{
                this.$alert("查询失败，请检查网络！", {
                    confirmButtonText: "确定",
                    customClass: "alertFailure"
                })
            })
        },
        //箭头左右切换
        tapSave(){
           this.isSave=!this.isSave 
        },
        fileDownload(filename,url,type){
           this.$http.getFullFilePath({
            'url': url
            }).then(({ data }) => {
                if (data.code == 200) {
                    let allFileName = ""
                    allFileName = (type == 'pdf') ? filename + '.pdf' : filename
                    download(allFileName,data.rows[0].fileName)
                    // download(`${filename}.pdf`,data.rows[0].fileName)
                } else {
                    showAlert({
                        msg: `操作失败：${data.info}`,
                        type: 0
                    })
                }
            })
            .catch((error) => {
                showAlert({
                    msg: `查询失败，请检查网络！`,
                    type: 0
                })
            })
        },
        sureSave(){
            this.$confirm('是否确认核对无误？').then(_ => {
                if(this.pactNo){
                    this.pactValue++
                    this.pactNo=false
                }
                if(this.messageNo){
                    this.messageValue++
                    this.messageNo=false
                }
            })
            .catch(_ => {})
            
        }
    },
    components:{
        pagination
    }
}
</script>
